package com.dyw.ycgovfinance.adapter.list;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dyw.ycgovfinance.R;
import com.dyw.ycgovfinance.bean.NewsListBean;

import java.util.List;

/**
 * Created by Administrator on 2017/6/21.
 */

public class ListAdapterForNews extends BaseAdapter {
    private List<NewsListBean> datas;
    private Context context;
    private String newsKind;


    public ListAdapterForNews(List<NewsListBean> datas, Context context,String newsKind) {
        this.datas = datas;
        this.context = context;
        this.newsKind = newsKind;
    }


    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder myViewHolder = null;
        if (convertView == null) {
            myViewHolder = new MyViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.list_item_news, null);
            myViewHolder.tvTitle = (TextView) convertView.findViewById(R.id.tv_title);
            myViewHolder.tvContent = (TextView) convertView.findViewById(R.id.tv_content);
            myViewHolder.tvNewsKind = (TextView) convertView.findViewById(R.id.tv_news_kind);
            myViewHolder.tvNewsTime = (TextView) convertView.findViewById(R.id.tv_news_time);
            convertView.setTag(myViewHolder);
        } else {
            myViewHolder = (MyViewHolder) convertView.getTag();
        }
        NewsListBean newsListBean = datas.get(position);
        myViewHolder.tvTitle .setText(newsListBean.getTitle());
        myViewHolder.tvContent.setText(Html.fromHtml(newsListBean.getRemark()));
        myViewHolder.tvNewsTime .setText(newsListBean.getSend_time());
        myViewHolder.tvNewsKind .setText(newsKind);
        return convertView;
    }


    static class MyViewHolder {
        private TextView tvNewsKind;
        private TextView tvNewsTime;
        private TextView tvTitle;
        private TextView tvContent;







    }
}

